﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace WebAPITest.Controllers
{
    public class ValuesController : ApiController
    {
        // GET api/values
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5
        public string Get(int id)
        {
            return "value";
        }

        //POST api/values
        //[HttpPost]
        //public object PostMethod([FromBody]IllegalDataModel1 value)
        //{
        //    #region 调试1
        //    //string val = JsonConvert.SerializeObject(value);
        //    //Console.WriteLine(val);

        //    //ReturnDataModel model = new ReturnDataModel();
        //    //model.code = "200";
        //    //model.message = "操作成功"; 
        //    #endregion

        //    #region 调试2

        //    ResponseModel1400 model = new ResponseModel1400();
        //    ReturnModel1400 m1 = new ReturnModel1400();
        //    m1.Id = "1";
        //    m1.StatusString = "success";
        //    m1.StatusCode = "0";
        //    m1.RequestURL = "/apifox/test1/";
        //    m1.LocalTime = DateTime.Now.ToLongDateString();
        //    model.ResponseStatusObject = m1;

        //    #endregion

        //    return model;
        //}

        [HttpPost]
        public object PostMethod()
        {
            #region 调试1
            //string val = JsonConvert.SerializeObject(value);
            //Console.WriteLine(val);

            //ReturnDataModel model = new ReturnDataModel();
            //model.code = "200";
            //model.message = "操作成功"; 
            #endregion

            #region 调试2

            ResponseModel1400 model = new ResponseModel1400();
            ReturnModel1400 m1 = new ReturnModel1400();
            m1.Id = "1";
            m1.StatusString = "success";
            m1.StatusCode = "0";
            m1.RequestURL = "/apifox/test1/";
            m1.LocalTime = DateTime.Now.ToLongDateString();
            model.ResponseStatusObject = m1;

            #endregion

            return model;
        }

        //[HttpPost]
        //public object Keepalive([FromBody]KeepaliveModelRequest value)
        //{
        //    ResponseModel1400 model = new ResponseModel1400();
        //    ReturnModel1400 m1 = new ReturnModel1400();
        //    m1.Id = "1";
        //    m1.StatusString = "success";
        //    m1.StatusCode = "0";
        //    m1.RequestURL = "/apifox/test1/";
        //    m1.LocalTime = DateTime.Now.ToLongDateString();
        //    model.ResponseStatusObject = m1;

        //    return model;
        //}

        //[HttpPost]
        //public object Register([FromBody]RegisterModelRequest value)
        //{
        //    ResponseModel1400 model = new ResponseModel1400();
        //    ReturnModel1400 m1 = new ReturnModel1400();
        //    m1.Id = "1";
        //    m1.StatusString = "success";
        //    m1.StatusCode = "0";
        //    m1.RequestURL = "/apifox/test1/";
        //    m1.LocalTime = DateTime.Now.ToLongDateString();
        //    model.ResponseStatusObject = m1;

        //    return model;
        //}

        //[HttpPost]
        //public object UnRegister([FromBody]UnRegisterModelRequest value)
        //{
        //    ResponseModel1400 model = new ResponseModel1400();
        //    ReturnModel1400 m1 = new ReturnModel1400();
        //    m1.Id = "1";
        //    m1.StatusString = "success";
        //    m1.StatusCode = "0";
        //    m1.RequestURL = "/apifox/test1/";
        //    m1.LocalTime = DateTime.Now.ToLongDateString();
        //    model.ResponseStatusObject = m1;

        //    return model;
        //}

        [HttpPut]
        public object PtMethod([FromBody]AlxaillegalModel value,string v1)
        {
            //int s = int.Parse(value.kkbh2);
            string val = JsonConvert.SerializeObject(value);
            Console.WriteLine(val);

            AlxaReturnDataModel model = new AlxaReturnDataModel();
            model.error_code = "0000000000";
            model.message = "ok";

            return model;
        }

        //[HttpPost]
        //public string Method2(string str1,string str2)
        //{
        //    ReturnDataModel model = new ReturnDataModel();
        //    model.code = "200";
        //    model.message = "操作成功";

        //    return "200";
        //}

        // PUT api/values/5
        //public void Put(int id, [FromBody]string value)
        //{
        //}
        [HttpPut]
        public object Put([FromBody]AlxaillegalModel value)
        {
            string val = JsonConvert.SerializeObject(value);
            Console.WriteLine(val);

            AlxaReturnDataModel model = new AlxaReturnDataModel();
            model.error_code = "0000000000";
            model.message = "ok";
            return model;
        }

        // DELETE api/values/5
        public void Delete(int id)
        {
            //在损失函数中添加权值惩罚项（如L2正则化限制权重过大），减少模型复杂度[1](@ref)[2](@ref)[4](@ref)。 
        }
    }
}
